﻿Imports Microsoft.TeamFoundation.WorkItemTracking.Client

Public Class WIItemFieldConverter
    Implements IValueConverter


    Public Function Convert(ByVal value As Object, ByVal targetType As System.Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.Convert
        Try
            Dim wi As WorkItem = value
            Dim Param As String = parameter
            If Not wi.Fields.Contains(Param) Then Return "unknown"
            Return wi.Fields(Param).Value
        Catch ex As Exception
            Return ex.Message
        End Try

    End Function

    Public Function ConvertBack(ByVal value As Object, ByVal targetType As System.Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.ConvertBack
        ' do nothing
        Return Nothing
    End Function

End Class
